/**
 * Copyright (c) 2012-2013 Nokia Corporation. All rights reserved.
 * Nokia and Nokia Connecting People are registered trademarks of Nokia Corporation. 
 * Oracle and Java are trademarks or registered trademarks of Oracle and/or its
 * affiliates. Other product and company names mentioned herein may be trademarks
 * or trade names of their respective owners. 
 * See LICENSE.TXT for license information.
 */
package com.nokia.example.fuelcalculator.view;

import java.io.IOException;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;

/**
 * This is the splash screen.
 */
public class SplashCanvas extends Canvas{
    private String imageName;
    private String text;
    
    public SplashCanvas(String imageName, String text) {
        super();
        this.imageName = imageName;
        this.text = text;
    }
    
    protected void paint(Graphics g) {
        int width = getWidth();
        int height = getHeight();

        g.setColor(0x0000ff);
        g.fillRect(0, 0, width, height);

        try {
            Image sp = Image.createImage(imageName);
            g.drawImage(sp, width / 2, height / 2, Graphics.VCENTER | Graphics.HCENTER);
        } catch (IOException ex) {
            // nop
        }
        g.setColor(0x000000);
        g.drawString(text, width / 2, 25, Graphics.BASELINE | Graphics.HCENTER);
    }
}
